package eCheque;

/**
 * Manager class for retrieving account information. All account related
 * operation should be executed through this class.
 * 
 * @author Steve Pennington
 * 
 */
public class AccountManager {

	private static AccountManager instance = new AccountManager();

	public static AccountManager getInstance() {
		return instance;
	}

	/**
	 * Retrieve the account balance from the bank server
	 * 
	 * @param account
	 *            Account to retrieve the balance from
	 * @param handler
	 *            Callback for handling server response
	 */
	public void getBalance(EChequeRegisteration account, ResponseHandler handler) {
		Runnable client = new EchequeClient(EchequeClient.PORT_NUMBER,
				EchequeClient.ACTION_BALANCE, account.getBankAddress(),
				account, null, handler);
		Thread clientRunner = new Thread(client);
		clientRunner.start();
	}
}
